"use strict";

function rand_range(min, max) {
	return Math.floor(Math.random() * (max - min + 1) + min);
}

function shuffle(deck) {
	var i, temp, deck_size, new_slot;
	deck_size = deck.length;
	for (i = 0; i < deck_size - 1; ++i) {
		temp = deck[i];
		new_slot = rand_range(i + 1, deck_size - 1);
		deck[i] = deck[new_slot];
		deck[new_slot] = temp;
	}	
}

function getWorkRequestFromState(state, participant) {
	if ("work_requests_" + participant in state) {
		return JSON.parse(state["work_requests_" + participant]);
	}
	return null;
}
